cmake_minimum_required(VERSION 2.8.4)
project(hk_opencv_example)

## Compile as C++11
set(CMAKE_CXX_STANDARD 11)
if (NOT CMAKE_BUILD_TYPE)
    # Options: Debug, Release, MinSizeRel, RelWithDebInfo
    set(CMAKE_BUILD_TYPE "Release")
    message(STATUS "No build type selected, default to ${CMAKE_BUILD_TYPE}")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -Wall  -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall   -O3 -march=native")

# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
   add_definitions(-DCOMPILEDWITHC11)
   message(STATUS "Using flag -std=c++11.")
elseif(COMPILER_SUPPORTS_CXX0X)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
   add_definitions(-DCOMPILEDWITHC0X)
   message(STATUS "Using flag -std=c++0x.")
else()
   message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Find ROS package
find_package(catkin REQUIRED COMPONENTS
    roscpp
    sensor_msgs
    cv_bridge
    image_transport
    geometry_msgs
    nav_msgs
    )

#ROS package include
catkin_package(
    LIBRARIES ${PROJECT_NAME}
    CATKIN_DEPENDS
    roscpp 
    sensor_msgs 
    std_msgs
    geometry_msgs
    cv_bridge
    image_transport
    nav_msgs
    )

# Find dependent libraries
find_package(OpenCV 3 REQUIRED)
message(STATUS "OpenCV Version: " ${OpenCV_VERSION})

# hikvision libs

set(hik_dir ${PROJECT_SOURCE_DIR}/lib)
link_directories(${hik_dir})

set(hik_libs 
libAudioRender.so
libcrypto.so
libHCCore.so
libhcnetsdk.so
libhpr.so
libNPQos.so
libPlayCtrl.so
libssl.so
libSuperRender.so
libz.so
)

# Include header files
include_directories(
include 
${OpenCV_INCLUDE_DIRS} 
${PROJECT_SOURCE_DIR}
${catkin_INCLUDE_DIRS}
)

# Create the executables and link them to libs
add_executable(hk_opencv_example 
consoleMain.cpp
HiK_opencv.h
HiK_opencv.cpp

public.h

PlayM4.h
HCNetSDK.h
)
target_link_libraries(hk_opencv_example 
${OpenCV_LIBS} 
${hik_libs} 
${catkin_LIBRARIES}
)


